'''
Created on 2010-1-3

@author: wangyongtao
'''

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import os
import logging
import utility
import supportapp
import iphoneapp
import androidapp

class IndexHandler(utility.BaseRequestHandler):
    def get(self):
        self.generate('home.html')

class AboutHandler(utility.BaseRequestHandler):
    def get(self):
        self.generate("about.index.html", {'app_name':'About - Taobility Software',
                                           'selected' : 'about',})

mainApplication = webapp.WSGIApplication([
            ('/support.*', supportapp.IndexHandler),
            ('/about.*', AboutHandler),
            ('/iphone.*', iphoneapp.IndexHandler),
            (r'/android/(.*)', androidapp.AppHandler),
            ('/android.*', androidapp.IndexHandler),
            ('/.*', IndexHandler),
            ], debug=utility.DEBUG)

supportApplication = webapp.WSGIApplication([
            ('/.*', supportapp.IndexHandler),
            ], debug=utility.DEBUG)

iphoneApplication = webapp.WSGIApplication([
            ('/.*', iphoneapp.IndexHandler),
            ], debug=utility.DEBUG)

applications = {
  'taobility.appspot.com': mainApplication,
  'localhost':mainApplication,
  'www.taobility.com': mainApplication,
  'support.taobility.com': supportApplication,
  'iphone.taobility.com': iphoneApplication,
  'support.localhost':supportApplication,
}
       
def main():
    run_wsgi_app(applications[os.environ['SERVER_NAME']])

if __name__ == "__main__":
    main()        